﻿using HMACAuthentication.WebApi.Filters;
using YMJF_Service.Common;
using YMJF_Service.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace YMJF_Service.Controllers
{
    /// <summary>
    /// 栏目管理
    /// </summary>
    [RoutePrefix("api/column")]
    [HMACAuthenticationAttribute]
    public class ColumnController : ApiController
    {

       /// <summary>
        /// 添加栏目
       /// </summary>
       /// <param name="data">栏目信息</param>
       /// <returns></returns>
        [HttpPost]
        [Route("Add")]
        public ApiResult AddColumn(column data)
        {
            ApiResult res = new ApiResult();

            try
            {
               
                string user = "admin";

                //data.ID = Guid.NewGuid().ToString();
                data.SysOrder = 9999;
                data.SysCreatedBy = user;
                data.SysCreate = DateTime.Now;
                data.SysLastUpdBy = user;
                data.SysLastUpd = DateTime.Now;
                data.SysDeleted = false;
                object obj = data.Insert();
                if (obj != null)
                {
                    res.code = HttpCode.success;
                    res.message = "添加成功";
                }
                else
                {
                    res.code = HttpCode.Add_Failed;
                    res.message = "添加失败";
                }

            }
            catch (Exception ex)
            {
                MessageBL.Insert(new MessageBL(MessageType.Exception, "column", "添加栏目错误：" + ex.Message));
                res.code = HttpCode.fail;
                res.message = ex.Message;
            }
            return res;

        }



    }
}
